package com.ssy.lingxi.report.serviceimpl.tally;

import com.ssy.lingxi.report.api.enums.*;
import com.ssy.lingxi.report.api.vo.request.OperateNoticeVO;
import com.ssy.lingxi.report.dao.merchantmember.MemberDAO;
import com.ssy.lingxi.report.entity.report.MemberTallyReportDO;
import com.ssy.lingxi.report.model.bo.MemberTallyReportBO;
import com.ssy.lingxi.report.model.bo.StatisticsCountBO;
import com.ssy.lingxi.report.model.bo.tally.*;
import com.ssy.lingxi.report.model.bo.tally.statistics.*;
import com.ssy.lingxi.report.model.vo.response.MemberTallyReportVO;
import com.ssy.lingxi.report.model.vo.response.TallyReportItemVO;
import com.ssy.lingxi.report.service.tally.IMemberTallyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 会员计数接口定义实现
 * @author 伍将
 * @date 2020/11/21
 * @version 2.0.0
 */
@Service
public class MemberTallyServiceImpl implements IMemberTallyService {

    private static final Logger logger = LoggerFactory.getLogger(MemberTallyServiceImpl.class);

    @Resource
    private MemberDAO memberDAO;

    @Override
    public MemberTallyReportVO convertMember(MemberTallyReportBO tallyBO){
        MemberTallyReportVO result = new MemberTallyReportVO();
        // 转换会员入库数据
        result.setImportList(convertMemberImportTally(tallyBO.getMemberImportTallyBO()));
        // 转换会员变更数据
        result.setChangeList(convertMemberChangeTally(tallyBO.getMemberChangeTallyBO()));
        // 转换会员考评数据
        result.setKpiList(convertMemberKpiTally(tallyBO.getMemberKpiTallyBO()));
        // 转换会员整改数据
        result.setRectifyList(convertMemberRectifyTally(tallyBO.getMemberRectifyTallyBO()));
        // 转换会员整改通知数据
        result.setRectifyNoticeList(convertMemberRectifyNoticeTally(tallyBO.getMemberRectifyNoticeTallyBO()));
        // 转换平台会员审核数据
        result.setPlatformList(convertPlatformMemberVerifyTally(tallyBO.getPlatformMemberVerifyTallyBO()));
        return result;
    }

    /**
     * 转换会员入库
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertMemberImportTally(MemberImportTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new MemberImportTallyBO();
        }
        // 待审核入库资料
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyInfoCount());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_VALIFY_INFO.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_VALIFY_INFO.getLink());
        resultList.add(tallyReportItem);
        // 待审核入库资质
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyQualificationCount());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_VALIFY_QUALIFICATION.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_VALIFY_QUALIFICATION.getLink());
        resultList.add(tallyReportItem);
        // 待入库考察
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeImportExploreCount());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_IMPORT_EXPLORE.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_IMPORT_EXPLORE.getLink());
        resultList.add(tallyReportItem);
        // 待入库分类
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeImportClassifyCount());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_IMPORT_CLASSIFY.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_IMPORT_CLASSIFY.getLink());
        resultList.add(tallyReportItem);
        // 待一级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待二级审核
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认审核结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount());
        tallyReportItem.setName(MemberImportOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(MemberImportOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换会员变更
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertMemberChangeTally(MemberChangeTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new MemberChangeTallyBO();
        }
        // 待审核会员变更(一级)
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(MemberChangeOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(MemberChangeOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        // 待审核会员变更(二级)
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(MemberChangeOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(MemberChangeOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        // 待确认会员变更
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount());
        tallyReportItem.setName(MemberChangeOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(MemberChangeOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换会员考评
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertMemberKpiTally(MemberKpiTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new MemberKpiTallyBO();
        }
        // 待发布考评表
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBePublishCount());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_PUBLISH_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_PUBLISH_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待考评打分
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeScoringCount());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_SCORING_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_SCORING_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待提交汇总考评结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待审核考评结果(一级)
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待审核考评结果(二级)
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待通报考评结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeNoticeCount());
        tallyReportItem.setName(MemberKpiOperateTypeEnum.TO_BE_NOTICE_COUNT.getName());
        tallyReportItem.setLink(MemberKpiOperateTypeEnum.TO_BE_NOTICE_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换会员整改
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertMemberRectifyTally(MemberRectifyTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new MemberRectifyTallyBO();
        }
        // 待发送整改通知
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeSendNoticeCount());
        tallyReportItem.setName(MemberRectifyOperateTypeEnum.TO_BE_SEND_NOTICE_COUNT.getName());
        tallyReportItem.setLink(MemberRectifyOperateTypeEnum.TO_BE_SEND_NOTICE_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待确认整改结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmNoticeCount());
        tallyReportItem.setName(MemberRectifyOperateTypeEnum.TO_BE_CONFIRM_NOTICE_COUNT.getName());
        tallyReportItem.setLink(MemberRectifyOperateTypeEnum.TO_BE_CONFIRM_NOTICE_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换会员整改通知
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertMemberRectifyNoticeTally(MemberRectifyNoticeTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new MemberRectifyNoticeTallyBO();
        }
        // 待发送整改通知
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeRectifyCount());
        tallyReportItem.setName(MemberRectifyNoticeOperateTypeEnum.TO_BE_RECTIFY_COUNT.getName());
        tallyReportItem.setLink(MemberRectifyNoticeOperateTypeEnum.TO_BE_RECTIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换会员整改通知
     * @param tallyBO
     * @return
     */
    public List<TallyReportItemVO> convertPlatformMemberVerifyTally(PlatformMemberVerifyTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PlatformMemberVerifyTallyBO();
        }
        //待提交审核数
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount());
        tallyReportItem.setName(MemberOperateTypeEnum.TO_BE_COMMIT_VALIFY.getName());
        tallyReportItem.setLink(MemberOperateTypeEnum.TO_BE_COMMIT_VALIFY.getLink());
        resultList.add(tallyReportItem);
        //待一级审核数
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count());
        tallyReportItem.setName(MemberOperateTypeEnum.TO_BE_VALIFY_STEP1.getName());
        tallyReportItem.setLink(MemberOperateTypeEnum.TO_BE_VALIFY_STEP1.getLink());
        resultList.add(tallyReportItem);
        //待二级审核数
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count());
        tallyReportItem.setName(MemberOperateTypeEnum.TO_BE_VALIFY_STEP2.getName());
        tallyReportItem.setLink(MemberOperateTypeEnum.TO_BE_VALIFY_STEP2.getLink());
        resultList.add(tallyReportItem);
        //待确认审核结果数
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getTobeConfirmCount());
        tallyReportItem.setName(MemberOperateTypeEnum.TO_BE_CONFIRM.getName());
        tallyReportItem.setLink(MemberOperateTypeEnum.TO_BE_CONFIRM.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 设置会员
     * @param tallyReportBO 会员计数报表
     * @param noticeVO 操作通知VO
     * @return 会员计数报表
     */
    @Override
    public MemberTallyReportBO setMemberTally(MemberTallyReportBO tallyReportBO, OperateNoticeVO noticeVO) {

        OperateDataSourceEnum sourceEnum = OperateDataSourceEnum.getEnum(noticeVO.getDataSource());
        switch (sourceEnum) {
            case MEMBER_IMPORT: // 转换会员入库数据
                tallyReportBO.setMemberImportTallyBO(setMemberImportTally(tallyReportBO.getMemberImportTallyBO(), noticeVO));
                break;
            case MEMBER_CHANGE: // 转换会员变更数据
                tallyReportBO.setMemberChangeTallyBO(setMemberChangeTally(tallyReportBO.getMemberChangeTallyBO(), noticeVO));
                break;
            case MEMBER_KPI: // 转换会员考评数据
                tallyReportBO.setMemberKpiTallyBO(setMemberKpiTally(tallyReportBO.getMemberKpiTallyBO(), noticeVO));
                break;
            case MEMBER_RECTIFY: // 转换会员整改数据
                tallyReportBO.setMemberRectifyTallyBO(setMemberRectifyTally(tallyReportBO.getMemberRectifyTallyBO(), noticeVO));
                break;
            case MEMBER_RECTIFY_NOTICE: // 转换会员整改通知数据
                tallyReportBO.setMemberRectifyNoticeTallyBO(setMemberRectifyNoticeTally(tallyReportBO.getMemberRectifyNoticeTallyBO(), noticeVO));
                break;
            case PLATFORM_MEMBER_VERIFY: // 转换平台会员审核数据
                tallyReportBO.setPlatformMemberVerifyTallyBO(setPlatformMemberVerifyTally(tallyReportBO.getPlatformMemberVerifyTallyBO(), noticeVO));
                break;
        }
        return tallyReportBO;
    }


    /**
     * 设置会员入库数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private MemberImportTallyBO setMemberImportTally(MemberImportTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new MemberImportTallyBO();
        }
        // 更新数据
        MemberImportOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberImportOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_INFO:
                        tallyBO.setToBeValifyInfoCount(tallyBO.getToBeValifyInfoCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_QUALIFICATION:
                        tallyBO.setToBeValifyQualificationCount(tallyBO.getToBeValifyQualificationCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_IMPORT_EXPLORE:
                        tallyBO.setToBeImportExploreCount(tallyBO.getToBeImportExploreCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_IMPORT_CLASSIFY:
                        tallyBO.setToBeImportClassifyCount(tallyBO.getToBeImportClassifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberImportOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_INFO:
                        tallyBO.setToBeValifyInfoCount(tallyBO.getToBeValifyInfoCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_QUALIFICATION:
                        tallyBO.setToBeValifyQualificationCount(tallyBO.getToBeValifyQualificationCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_IMPORT_EXPLORE:
                        tallyBO.setToBeImportExploreCount(tallyBO.getToBeImportExploreCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_IMPORT_CLASSIFY:
                        tallyBO.setToBeImportClassifyCount(tallyBO.getToBeImportClassifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    /**
     * 设置会员变更数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private MemberChangeTallyBO setMemberChangeTally(MemberChangeTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new MemberChangeTallyBO();
        }
        // 更新数据
        MemberChangeOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberChangeOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberChangeOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }
    /**
     * 设置会员考评数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private MemberKpiTallyBO setMemberKpiTally(MemberKpiTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new MemberKpiTallyBO();
        }
        // 更新数据
        MemberKpiOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberKpiOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_PUBLISH_COUNT:
                        tallyBO.setToBePublishCount(tallyBO.getToBePublishCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_SCORING_COUNT:
                        tallyBO.setToBeScoringCount(tallyBO.getToBeScoringCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_NOTICE_COUNT:
                        tallyBO.setToBeNoticeCount(tallyBO.getToBeNoticeCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberKpiOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_PUBLISH_COUNT:
                        tallyBO.setToBePublishCount(tallyBO.getToBePublishCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_SCORING_COUNT:
                        tallyBO.setToBeScoringCount(tallyBO.getToBeScoringCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_NOTICE_COUNT:
                        tallyBO.setToBeNoticeCount(tallyBO.getToBeNoticeCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }
    /**
     * 设置会员考评数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private MemberRectifyTallyBO setMemberRectifyTally(MemberRectifyTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new MemberRectifyTallyBO();
        }
        // 更新数据
        MemberRectifyOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberRectifyOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SEND_NOTICE_COUNT:
                        tallyBO.setToBeSendNoticeCount(tallyBO.getToBeSendNoticeCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_NOTICE_COUNT:
                        tallyBO.setToBeConfirmNoticeCount(tallyBO.getToBeConfirmNoticeCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberRectifyOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SEND_NOTICE_COUNT:
                        tallyBO.setToBeSendNoticeCount(tallyBO.getToBeSendNoticeCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_NOTICE_COUNT:
                        tallyBO.setToBeConfirmNoticeCount(tallyBO.getToBeConfirmNoticeCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    /**
     * 设置会员整改通知
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private MemberRectifyNoticeTallyBO setMemberRectifyNoticeTally(MemberRectifyNoticeTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new MemberRectifyNoticeTallyBO();
        }
        // 更新数据
        MemberRectifyNoticeOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberRectifyNoticeOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                if (typeEnum == MemberRectifyNoticeOperateTypeEnum.TO_BE_RECTIFY_COUNT) {
                    tallyBO.setToBeRectifyCount(tallyBO.getToBeRectifyCount() - noticeVO.getReduceCount());
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberRectifyNoticeOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                if (typeEnum == MemberRectifyNoticeOperateTypeEnum.TO_BE_RECTIFY_COUNT) {
                    tallyBO.setToBeRectifyCount(tallyBO.getToBeRectifyCount() + noticeVO.getIncreaseCount());
                }
            }
        }
        return tallyBO;
    }
    /**
     * 设置平台会员审核
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private PlatformMemberVerifyTallyBO setPlatformMemberVerifyTally(PlatformMemberVerifyTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PlatformMemberVerifyTallyBO();
        }
        // 更新数据
        MemberOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setTobeConfirmCount(tallyBO.getTobeConfirmCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM:
                        tallyBO.setTobeConfirmCount(tallyBO.getTobeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    /**
     * 设置会员
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    @Override
    public MemberTallyReportBO setMember(MemberTallyReportBO tallyBO, OperateNoticeVO noticeVO) {
        if (!OperateDataSourceEnum.MEMBER.getCode().equals(noticeVO.getDataSource())) {
            return tallyBO;
        }
        if (tallyBO == null) {
            tallyBO = new MemberTallyReportBO();
        }
        MemberTallyBO reportBO = tallyBO.getMemberTallyReport();
        if (reportBO == null) {
            reportBO = new MemberTallyBO();
        }
        // 更新数据
        MemberOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = MemberOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY:
                        reportBO.setToBeCommitValifyCount(reportBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        reportBO.setToBeValifyStep1Count(reportBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        reportBO.setToBeValifyStep2Count(reportBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM:
                        reportBO.setTobeConfirmCount(reportBO.getTobeConfirmCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = MemberOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY:
                        reportBO.setToBeCommitValifyCount(reportBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1:
                        reportBO.setToBeValifyStep1Count(reportBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2:
                        reportBO.setToBeValifyStep2Count(reportBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM:
                        reportBO.setTobeConfirmCount(reportBO.getTobeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        tallyBO.setMemberTallyReport(reportBO);

        return tallyBO;
    }


    /**
     * 统计计数
     * @param reportList
     * @return
     */
    @Override
    public List<MemberTallyReportDO> statisticsTally(List<MemberTallyReportDO> reportList) {

        // 会员入库
        reportList = statisticsImportTally(reportList);
        // 会员变更
        reportList = statisticsChangeTally(reportList);
        // 会员考评
        reportList = statisticsKpiTally(reportList);
        // 会员整改
        reportList = statisticsRectifyTally(reportList);
        // 会员整改通知
        reportList = statisticsRectifyNoticeTally(reportList);
        // 平台会员审核
        reportList = statisticsPlatformMemberVerifyTally(reportList);

        return reportList;
    }

    private List<MemberTallyReportDO> statisticsImportTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberImportStatisticsTallyVO> tallyVOList = memberDAO.getImportCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "会员入库");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberImportTallyBO tallyBO = new MemberImportTallyBO();
            MemberImportStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待审核入库资料
                tallyBO.setToBeValifyInfoCount(tallyVO.getToBeValifyInfo());
                // 待审核入库资质
                tallyBO.setToBeValifyQualificationCount(tallyVO.getToBeValifyQualification());
                // 待入库考察
                tallyBO.setToBeImportExploreCount(tallyVO.getToBeImportExplore());
                // 待入库分类
                tallyBO.setToBeImportClassifyCount(tallyVO.getToBeImportClassify());
                // 待审核入库(一级)
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1());
                // 待审核入库(二级)
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2());
                // 待确认入库
                tallyBO.setToBeConfirmCount(tallyVO.getToBeConfirm());
            }
            p.getTallyReport().setMemberImportTallyBO(tallyBO);
        });
        return finalReportList;
    }

    private List<MemberTallyReportDO> statisticsChangeTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberChangeStatisticsTallyVO> tallyVOList = memberDAO.getChangeCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "会员变更");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberChangeTallyBO tallyBO = new MemberChangeTallyBO();
            MemberChangeStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待审核会员变更(一级)
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1());
                // 待审核会员变更(二级)
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2());
                // 待确认会员变更
                tallyBO.setToBeConfirmCount(tallyVO.getToBeConfirm());
            }
            p.getTallyReport().setMemberChangeTallyBO(tallyBO);
        });
        return finalReportList;
    }

    /**
     * 会员考评统计
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsKpiTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberKpiStatisticsTallyVO> tallyVOList = memberDAO.getKpiCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "会员考评");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberKpiTallyBO tallyBO = new MemberKpiTallyBO();
            MemberKpiStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                //待发布考评表
                tallyBO.setToBePublishCount(tallyVO.getToBePublishCount());
                //待考评打分
                tallyBO.setToBeScoringCount(tallyVO.getToBeScoringCount());
                //待提交汇总考评结果
                tallyBO.setToBeCommitCount(tallyVO.getToBeCommitCount());
                // 待审核考评结果(一级)
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待审核考评结果(二级)
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待通报考评结果
                tallyBO.setToBeNoticeCount(tallyVO.getToBeNoticeCount());
            }
            p.getTallyReport().setMemberKpiTallyBO(tallyBO);
        });
        return finalReportList;
    }

    private List<MemberTallyReportDO> statisticsRectifyTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberRectifyStatisticsTallyVO> tallyVOList = memberDAO.getRectifyCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "会员整改");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberRectifyTallyBO tallyBO = new MemberRectifyTallyBO();
            MemberRectifyStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待发送整改通知
                tallyBO.setToBeSendNoticeCount(tallyVO.getToBeSendNoticeCount());
                //待确认整改结果
                tallyBO.setToBeConfirmNoticeCount(tallyVO.getToBeConfirmNoticeCount());
            }
            p.getTallyReport().setMemberRectifyTallyBO(tallyBO);
        });
        return finalReportList;
    }

    /**
     * 会员整改通知
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsRectifyNoticeTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberRectifyNoticeStatisticsTallyVO> tallyVOList = memberDAO.getRectifyNoticeCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "会员整改通知");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberRectifyNoticeTallyBO tallyBO = new MemberRectifyNoticeTallyBO();
            tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().ifPresent(tallyVO -> tallyBO.setToBeRectifyCount(tallyVO.getToBeRectifyCount()));
            p.getTallyReport().setMemberRectifyNoticeTallyBO(tallyBO);
        });
        return finalReportList;
    }

    /**
     * 平台会员审核
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsPlatformMemberVerifyTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<PlatformMemberVerifyStatisticsTallyVO> tallyVOList = memberDAO.getPlatformMemberVerifyCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = replenishData(reportList, statisticsList, "平台会员审核");

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            PlatformMemberVerifyTallyBO tallyBO = new PlatformMemberVerifyTallyBO();
            PlatformMemberVerifyStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待确认审核结果
                tallyBO.setTobeConfirmCount(tallyVO.getTobeConfirmCount());
            }
            p.getTallyReport().setPlatformMemberVerifyTallyBO(tallyBO);
        });
        return finalReportList;
    }


    /**
     * 统计计数
     * @param reportList
     * @return
     */
    public List<MemberTallyReportDO> statisticsTallyOld(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        List<MemberStatisticsTallyVO> tallyVOList = memberDAO.getStatisticsCount();
        List<StatisticsCountBO> statisticsList = tallyVOList.stream().map(r -> {
            StatisticsCountBO statisticsCountBO = new StatisticsCountBO();
            statisticsCountBO.setMemberId(r.getMemberId());
            statisticsCountBO.setRoleId(r.getRoleId());
            return statisticsCountBO;
        }).collect(Collectors.toList());

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = reportList;
        statisticsList.stream().distinct().forEach(p -> {
            MemberTallyReportDO reportDO = finalReportList.stream()
                    .filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId()))
                    .findFirst().orElse(null);
            if (reportDO == null) {
                reportDO = new MemberTallyReportDO();
                reportDO.setMemberId(p.getMemberId());
                reportDO.setRoleId(p.getRoleId());
                finalReportList.add(reportDO);
            }
        });

        finalReportList.forEach(p -> {
            // 如果报表数据为null，则实例化
            if (p.getTallyReport() == null) {
                p.setTallyReport(new MemberTallyReportBO());
            }
            MemberTallyBO tallyBO = new MemberTallyBO();
            MemberStatisticsTallyVO tallyVO = tallyVOList.stream().filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId())).findFirst().orElse(null);
            if (null != tallyVO) {
                // 待提交审核数
                tallyBO.setToBeCommitValifyCount(tallyVO.getToBeCommitValifyCount());
                // 待一级审核数
                tallyBO.setToBeValifyStep1Count(tallyVO.getToBeValifyStep1Count());
                // 待二级审核数
                tallyBO.setToBeValifyStep2Count(tallyVO.getToBeValifyStep2Count());
                // 待确认审核结果
                tallyBO.setTobeConfirmCount(tallyVO.getTobeConfirmCount());
            }
            p.getTallyReport().setMemberTallyReport(tallyBO);
        });

        return finalReportList;
    }

    /**
     * 补全数据
     * @param reportList
     * @param statisticsList
     * @param name
     * @return
     */
    private List<MemberTallyReportDO> replenishData(List<MemberTallyReportDO> reportList, List<StatisticsCountBO> statisticsList, String name) {
        if (statisticsList == null) {
            logger.info("没有符合条件的{}计数统计数据", name);
            statisticsList = new ArrayList<>();
        }

        // 补全统计数据
        List<MemberTallyReportDO> finalReportList = reportList;
        statisticsList.stream().distinct().forEach(p -> {
            MemberTallyReportDO reportDO = finalReportList.stream()
                    .filter(o -> o.getMemberId().equals(p.getMemberId()) && o.getRoleId().equals(p.getRoleId()))
                    .findFirst().orElse(null);
            if (reportDO == null) {
                reportDO = new MemberTallyReportDO();
                reportDO.setMemberId(p.getMemberId());
                reportDO.setRoleId(p.getRoleId());
                finalReportList.add(reportDO);
            }
        });
        return finalReportList;
    }
}
